#pragma once

template<class T>
class TValidObject
{
public:
	TValidObject(void* lpObj)
	{
		size_t cbObject = sizeof( T );
		mbValid = ( !::IsBadReadPtr( lpObj, cbObject ) &&  !::IsBadWritePtr( lpObj, cbObject ) );
	}
	operator BOOL()
	{
		return mbValid;
	}
private:
	BOOL mbValid;
};
